package com.inkyi.assistant.app.component.rsyntax.action;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class FontSizeAction implements ActionListener {

    private final RSyntaxTextArea textArea;


    public FontSizeAction(RSyntaxTextArea textArea) {
        this.textArea = textArea;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Font oldFont = textArea.getFont();
        String fontName = oldFont.getFontName();
        JComboBox<String> source = (JComboBox<String>) e.getSource();
        String selectedItem = (String) source.getSelectedItem();
        Font font = new Font(fontName, Font.PLAIN, Integer.valueOf(selectedItem));
        textArea.setFont(font);
    }
}
